package com.sambo.inspection.util;

import android.util.Log;

import com.sambo.inspection.bean.PartitionBean;

import java.util.Map;

/**
 * Created by xulc on 2018/7/27.
 */

public class TreeUtils {
    //第一级别为0
    public static int getLevel(PartitionBean treePoint, Map<String, PartitionBean> map) {
        if ("0".equals(treePoint.getPid())) {
            return 0;
        } else {
            return 1 + getLevel(getTreePoint(treePoint.getPid(), map), map);
        }
    }

    public static PartitionBean getTreePoint(String ID, Map<String, PartitionBean> map) {
        if (map.containsKey(ID)) {
            return map.get(ID);
        }
        Log.e("xlc", "ID:" + ID);
        return null;
    }
}
